package com.supply.dl.widget.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseViewHolder;
import com.supply.dl.R;
import com.supply.dl.bean.*;
import com.supply.dl.utils.DateUtils;
import com.supply.dl.utils.StringUtils;
import com.supply.dl.utils.Utils;
import com.supply.dl.view.MyGridView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by ${qianzhihe} on 2018/4/23.
 * 通用常规列表适配器（适用于：单种类型的item）
 * 1--工作主界面列表
 * 2--入库定位界面列表
 */
public class CommonNormalAdapter extends BaseAdapter {

    /**
     * 工作模块主界面
     */
    public static final int FLAG_WORK_MAIN = 1;
    /**
     * 入库定位界面
     */
    public static final int FLAG_IN_BOUND_LOCATION_MAIN = 11;

    /**
     * 通知单定位详情：物料列表
     */
    public static final int FLAG_IN_BOUND_LOCATION_DETAIL_MATREIEL_MAIN = 111;
    /**
     * 通知单定位详情：定位列表（入库）
     */
    public static final int FLAG_IN_BOUND_LOCATION_DETAIL_POSITION_MAIN = 112;
    /**
     * 通知单定位详情：定位列表（出库）
     */
    public static final int FLAG_IN_BOUND_LOCATION_DETAIL_POSITION_MAIN_OUT = 201;
    /**
     * 通知单批量定位：物料列表
     */
    public static final int FLAG_IN_BOUND_LOCATION_BATCH_MATREIEL_MAIN = 113;
    /**
     * 库位选择
     */
    public static final int FLAG_RESERVOIR_POSITION_CHOOSE_MAIN = 114;
    /**
     * 通知单入库详情：物料列表
     */
    public static final int FLAG_NOTICE_IN_BOUND_DETAILS_MATREIEL_MAIN = 115;
    /**
     * 通知单入库详情：作业列表
     */
    public static final int FLAG_NOTICE_IN_BOUND_DETAILS_WORK_MAIN = 116;
    /**
     * 通知单出库详情：物料列表
     */
    public static final int FLAG_NOTICE_OUT_BOUND_DETAILS_MATREIEL_MAIN = 117;
    /**
     * 通知单出库详情：作业列表
     */
    public static final int FLAG_NOTICE_OUT_BOUND_DETAILS_WORK_MAIN = 118;
    /**
     * 订单入库详情：物料列表
     */
    public static final int FLAG_ORDER_IN_BOUND_DETAILS_MATREIEL_MAIN = 119;
    /**
     * 订单入库详情：作业列表
     */
    public static final int FLAG_ORDER_IN_BOUND_DETAILS_WORK_MAIN = 120;
    /**
     * 订单出库详情：物料列表
     */
    public static final int FLAG_ORDER_OUT_BOUND_DETAILS_MATREIEL_MAIN = 121;
    /**
     * 订单出库详情：作业列表
     */
    public static final int FLAG_ORDER_OUT_BOUND_DETAILS_WORK_MAIN = 122;

    /**
     * 通知单批量作业界面、订单批量作业界面物料列表数据
     */
    public static final int FLAG_NOTICE_OR_ORDER_BATCH_WORK_MAIN_MATREIEL = 123;

    /**
     * 出库定位界面
     */
    public static final int FLAG_OUT_BOUND_LOCATION_MAIN = 21;

    /**
     * 订单入库界面
     */
    public static final int FLAG_ORDER_IN_BOUND_MAIN = 12;
    /**
     * 订单出库界面
     */
    public static final int FLAG_ORDER_OUT_BOUND_MAIN = 22;

    /**
     * 通知单入库界面
     */
    public static final int FLAG_NOTICE_LETTER_IN_BOUND_MAIN = 31;
    /**
     * 通知单出库界面
     */
    public static final int FLAG_SEND_LETTER_OUT_BOUND_MAIN = 32;

    /**
     * 收货确认界面
     */
    public static final int FLAG_RECEIVING_GOODS_MAIN = 41;
    /**
     * 发货确认界面
     */
    public static final int FLAG_SEND_GOODS_MAIN = 42;
    /**
     * 盘点管理界面
     */
    public static final int FLAG_CHECK_MANAGER_MAIN = 43;
    /**
     * 盘点明细
     */
    public static final int FLAG_CHECK_DEATILS_MAIN = 44;
    /**
     * 移库收货确认通知单
     */
    public static final int FLAG_CHANGE_AND_GET_NOTIFY_LIST_MAIN = 45;

    public int mAdapterFlag = -1;

    public CommonNormalAdapter(int layoutResId, @Nullable List<BaseItemBean> data) {
        super(layoutResId, data);
    }

    public CommonNormalAdapter(@Nullable List<BaseItemBean> data) {
        super(data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BaseItemBean item) {
        super.convert(helper, item);
        switch (mAdapterFlag) {
            case FLAG_WORK_MAIN://工作模块界面
                WorkFunctionBean workFunctionBean = (WorkFunctionBean) item.object;
                helper.setText(R.id.fragment_work_main_item_functionName, workFunctionBean.functionName);
                helper.setImageResource(R.id.fragment_work_main_item_functionImage, workFunctionBean.resId);
                helper.addOnClickListener(R.id.fragment_work_main_item_functionLayout);
                break;
            case FLAG_IN_BOUND_LOCATION_MAIN://入库定位界面列表
            case FLAG_OUT_BOUND_LOCATION_MAIN://出库定位界面列表
                if (mAdapterFlag == FLAG_IN_BOUND_LOCATION_MAIN) {
                    helper.setText(R.id.inbound_location_main_item_inboundNoticeLetterNo, getResourcesString(R.string.inboundNoticeLetterNo));
                } else {
                    helper.setText(R.id.inbound_location_main_item_inboundNoticeLetterNo, getResourcesString(R.string.outboundNoticeLetterNo));
                }
                InAndOutBoundLocationBean inBoundLocationBean = (InAndOutBoundLocationBean) item.object;
                helper.setText(R.id.inbound_location_main_item_purchaseContentTv, inBoundLocationBean.bussTypeName);//订单类型名称
                helper.setText(R.id.inbound_location_main_item_positionStatusName, inBoundLocationBean.positionStatusName);//定库状态名称
                helper.setText(R.id.inbound_location_main_item_purchasePersonNameTv, inBoundLocationBean.driverName);//驾驶员姓名
                helper.setText(R.id.inbound_location_main_item_carIdCardTv, inBoundLocationBean.carNo);//车牌号
                helper.setText(R.id.inbound_location_main_item_timeTv, StringUtils.isEmpty(String.valueOf(inBoundLocationBean.addTime)) ? "" : DateUtils.getSimpleDateTimeByMill(String.valueOf(inBoundLocationBean.addTime), DateUtils.DATE_TIME_FORMAT));//建单时间
                helper.setText(R.id.inbound_location_main_item_showInboundNoticeLetterNo, inBoundLocationBean.noticeOrderNo);//入库通知单号
                helper.setText(R.id.inbound_location_main_item_showERPNo, inBoundLocationBean.erpOrderNo);//ERP订单号

                if (!StringUtils.isEmpty(inBoundLocationBean.noticeOrderId)) {//通知单
                    helper.setText(R.id.inbound_location_main_item_purchaseTypeTv, getResourcesString(R.string.noticeLetter));
                    helper.setBackgroundRes(R.id.inbound_location_main_item_purchaseTypeTv, R.drawable.shape_notice_purple_bg);
                } else {//订单
                    helper.setText(R.id.inbound_location_main_item_purchaseTypeTv, getResourcesString(R.string.orderLetter));
                    helper.setBackgroundRes(R.id.inbound_location_main_item_purchaseTypeTv, R.drawable.shape_order_purple_bg);
                }
                helper.addOnClickListener(R.id.inbound_location_main_item_lyParent);
                break;
            case FLAG_NOTICE_LETTER_IN_BOUND_MAIN://通知单入库界面列表
            case FLAG_SEND_LETTER_OUT_BOUND_MAIN://通知单出库界面列表
                if (mAdapterFlag == FLAG_NOTICE_LETTER_IN_BOUND_MAIN) {
                    helper.setText(R.id.inbound_location_main_item_inboundNoticeLetterNo, getResourcesString(R.string.inboundNoticeLetterNo));
                } else {
                    helper.setText(R.id.inbound_location_main_item_inboundNoticeLetterNo, getResourcesString(R.string.outboundNoticeLetterNo));
                }
                InAndOutBoundLocationBean noticeInOrOutBoundBean = (InAndOutBoundLocationBean) item.object;
                helper.setText(R.id.inbound_location_main_item_purchaseContentTv, noticeInOrOutBoundBean.bussTypeName);//业务类型
                helper.setText(R.id.inbound_location_main_item_positionStatusName, noticeInOrOutBoundBean.orderTypeName);//订单类型
                helper.setText(R.id.inbound_location_main_item_purchasePersonNameTv, noticeInOrOutBoundBean.driverName);//驾驶员姓名
                helper.setText(R.id.inbound_location_main_item_carIdCardTv, noticeInOrOutBoundBean.carNo);//车牌号
                helper.setText(R.id.inbound_location_main_item_timeTv, StringUtils.isEmpty(String.valueOf(noticeInOrOutBoundBean.addTime)) ? "" : DateUtils.getSimpleDateTimeByMill(String.valueOf(noticeInOrOutBoundBean.addTime), DateUtils.DATE_TIME_FORMAT));//建单时间
                helper.setText(R.id.inbound_location_main_item_showInboundNoticeLetterNo, noticeInOrOutBoundBean.noticeOrderNo);//入库通知单号
                helper.setText(R.id.inbound_location_main_item_showERPNo, noticeInOrOutBoundBean.erpOrderNo);//ERP订单号
                helper.getView(R.id.inbound_location_main_item_purchaseTypeTv).setVisibility(View.INVISIBLE);
                helper.addOnClickListener(R.id.inbound_location_main_item_lyParent);
                break;
            case FLAG_ORDER_IN_BOUND_MAIN://订单入库界面
            case FLAG_ORDER_OUT_BOUND_MAIN://订单出库界面
                if (mAdapterFlag == FLAG_ORDER_IN_BOUND_MAIN) {
                    helper.setText(R.id.order_inbound_main_item_inboundNoticeLetterNo, getResourcesString(R.string.inbound_order_no));
                } else {
                    helper.setText(R.id.order_inbound_main_item_inboundNoticeLetterNo, getResourcesString(R.string.outbound_order_no));
                }
                OrderInAndOutBoundBean orderInBoundBean = (OrderInAndOutBoundBean) item.object;
                helper.setText(R.id.order_inbound_main_item_purchaseContentTv, orderInBoundBean.bussTypeName);//业务类型
                helper.setText(R.id.order_inbound_main_item_positionStatusName, orderInBoundBean.orderTypeName);//订单类型
                helper.setText(R.id.order_inbound_main_item_showTimeTv, StringUtils.isEmpty(String.valueOf(orderInBoundBean.addTime)) ? "" : DateUtils.getSimpleDateTimeByMill(String.valueOf(orderInBoundBean.addTime), DateUtils.DATE_TIME_FORMAT));//建单时间
                helper.setText(R.id.order_inbound_main_item_showInboundNoticeLetterNo, orderInBoundBean.orderNo);//入库通知单号
                helper.setText(R.id.order_inbound_main_item_showERPNo, orderInBoundBean.erpOrderNo);//erp订单号
                helper.addOnClickListener(R.id.order_inbound_main_item_lyParent);
                break;
            case FLAG_IN_BOUND_LOCATION_DETAIL_MATREIEL_MAIN://通知单定位详情：未定位、已定位（物料）列表
                MaterielPositionInfoBean materielPositionInfoBean = (MaterielPositionInfoBean) item.object;
                TextView tvLocationDetailMaterial = helper.getView(R.id.material_position_info_item_textView);
                tvLocationDetailMaterial.setText(materielPositionInfoBean.skuName);
                helper.addOnClickListener(R.id.materail_position_info_item_lyParent);
                setItemSelectedUI(tvLocationDetailMaterial, materielPositionInfoBean.isSelected);
                break;
            case FLAG_IN_BOUND_LOCATION_DETAIL_POSITION_MAIN://通知单定位详情
            case FLAG_IN_BOUND_LOCATION_DETAIL_POSITION_MAIN_OUT:
                if (item.object instanceof RecommendPositionInfoBean) {//未定位
                    RecommendPositionInfoBean recommendPositionInfoBean = (RecommendPositionInfoBean) item.object;
                    helper.setText(R.id.position_info_item_showReservoirPositionTv, recommendPositionInfoBean.recommendStockName);//库位
                    helper.setText(R.id.position_info_item_showStorehouseTv, recommendPositionInfoBean.recommendWhName);//仓库
                    helper.setText(R.id.position_info_item_showNumberForPieceTv, String.valueOf(recommendPositionInfoBean.amount));//数量
                    helper.setText(R.id.position_info_item_showWeightForTonTv, String.valueOf(recommendPositionInfoBean.weight));//重量
                    helper.setText(R.id.position_info_item_showVolumeForSquareTv, String.valueOf(recommendPositionInfoBean.volume));//体积
                } else if (item.object instanceof PositionInfoBean) {//已定位
                    PositionInfoBean positionInfoBean = (PositionInfoBean) item.object;
                    helper.setText(R.id.position_info_item_showReservoirPositionTv, positionInfoBean.stockName);//库位
                    helper.setText(R.id.position_info_item_showStorehouseTv, positionInfoBean.whName);//仓库
                    helper.setText(R.id.position_info_item_showNumberForPieceTv, String.valueOf(positionInfoBean.amount));//数量
                    helper.setText(R.id.position_info_item_showWeightForTonTv, String.valueOf(positionInfoBean.weight));//重量
                    helper.setText(R.id.position_info_item_showVolumeForSquareTv, String.valueOf(positionInfoBean.volume));//体积
                }

                if (mAdapterFlag == FLAG_IN_BOUND_LOCATION_DETAIL_POSITION_MAIN) { // 入库定位时，不显示
                    helper.getView(R.id.work_info_item_inventoryStatusTv).setVisibility(View.GONE);
                    helper.getView(R.id.work_info_item_showInventoryStatusTv).setVisibility(View.GONE);

                    helper.getView(R.id.work_info_item_inventoryTypeTv).setVisibility(View.GONE);
                    helper.getView(R.id.work_info_item_showInventoryTypeTv).setVisibility(View.GONE);

                    helper.getView(R.id.work_info_item_standardTv).setVisibility(View.GONE);
                    helper.getView(R.id.work_info_item_showStandardTv).setVisibility(View.GONE);

                    helper.getView(R.id.work_info_item_batchNumberTv).setVisibility(View.GONE);
                    helper.getView(R.id.work_info_item_showBatchNumberTv).setVisibility(View.GONE);
                } else {
                    if (item.object instanceof RecommendPositionInfoBean) {//未定位
                        RecommendPositionInfoBean recommendPositionInfoBean = (RecommendPositionInfoBean) item.object;
                        helper.setText(R.id.work_info_item_showInventoryStatusTv, recommendPositionInfoBean.stockStatusName);//库存状态
                        helper.setText(R.id.work_info_item_showInventoryTypeTv, recommendPositionInfoBean.stockTypeName);
                        helper.setText(R.id.work_info_item_showStandardTv, recommendPositionInfoBean.unitName);
                        helper.setText(R.id.work_info_item_showBatchNumberTv, recommendPositionInfoBean.batchNo);
                    } else if (item.object instanceof PositionInfoBean) {//已定位
                        PositionInfoBean positionInfoBean = (PositionInfoBean) item.object;
                        helper.setText(R.id.work_info_item_showInventoryStatusTv, positionInfoBean.stockStatusName);//库存状态
                        helper.setText(R.id.work_info_item_showInventoryTypeTv, positionInfoBean.stockTypeName);
                        helper.setText(R.id.work_info_item_showStandardTv, positionInfoBean.unitName);
                        helper.setText(R.id.work_info_item_showBatchNumberTv, positionInfoBean.batchNo);
                    }
                }

                helper.addOnClickListener(R.id.position_info_item_surePositionBtn)//确认定位
                        .addOnClickListener(R.id.position_info_item_positionDeleteTv)//删除
                        .addOnClickListener(R.id.position_info_item_showReservoirPositionTv);
                break;
            case FLAG_IN_BOUND_LOCATION_BATCH_MATREIEL_MAIN://通知单批量定位：物料列表
                MaterielPositionInfoBean batchLocationMaterielItemBean = (MaterielPositionInfoBean) item.object;
                TextView tvbatchLocationMateriel = helper.getView(R.id.material_position_info_item_textView);
                tvbatchLocationMateriel.setText(batchLocationMaterielItemBean.skuName);
                helper.addOnClickListener(R.id.materail_position_info_item_lyParent);
                setItemSelectedUI(tvbatchLocationMateriel, batchLocationMaterielItemBean.isSelected);
                break;
            case FLAG_NOTICE_OR_ORDER_BATCH_WORK_MAIN_MATREIEL://通知单批量作业、订单批量作业界面：物料列表
                MaterielBatchWorkBean batchWorkMaterielItemBean = (MaterielBatchWorkBean) item.object;
                TextView tvbatchWorkMateriel = helper.getView(R.id.material_position_info_item_textView);
                tvbatchWorkMateriel.setText(batchWorkMaterielItemBean.skuName);
                helper.addOnClickListener(R.id.materail_position_info_item_lyParent).addOnClickListener(R.id.batch_work_main_content_editShowStorehouse);
                setItemSelectedUI(tvbatchWorkMateriel, batchWorkMaterielItemBean.isSelected);
                break;
            case FLAG_RESERVOIR_POSITION_CHOOSE_MAIN://库位选择
//                helper.setText(R.id.reservoir_position_choose_item_showWarehouseNameTv, )//仓库名称
//                helper.setText(R.id.reservoir_position_choose_item_showWarehouseCodeTv, )//仓库编码
//                helper.setText(R.id.reservoir_position_choose_item_showReservoirPositionNameTv, )//库位名称
//                helper.setText(R.id.reservoir_position_choose_item_showStorageMaterialInventoryTv, )//入库物料库存
//                helper.setText(R.id.reservoir_position_choose_item_showQuantityAvailableForStorageTv, )//可入库数量
//                helper.setText(R.id.reservoir_position_choose_item_showCurrentQueuedVehicleTv, )//当前排队车辆
                ImageView checkIv = helper.getView(R.id.reservoir_position_choose_item_checkIv);
//                if (){
//                    checkIv.setImageResource(R.mipmap.check_selected);
//                }else {
//                    checkIv.setImageResource(R.mipmap.check_normal);
//                }
                break;
            case FLAG_NOTICE_IN_BOUND_DETAILS_MATREIEL_MAIN://通知单入库详情：未作业、已作业（物料）列表
            case FLAG_NOTICE_OUT_BOUND_DETAILS_MATREIEL_MAIN://通知单出库详情：未作业、已作业（物料）列表
                WorkInfoBean workInfoBean = (WorkInfoBean) item.object;
                TextView tvBoundMaterial = helper.getView(R.id.material_position_info_item_textView);
                tvBoundMaterial.setText(workInfoBean.skuName);
                helper.addOnClickListener(R.id.materail_position_info_item_lyParent);
                setItemSelectedUI(tvBoundMaterial, workInfoBean.isSelected);
                break;
            case FLAG_NOTICE_IN_BOUND_DETAILS_WORK_MAIN://通知单入库详情：单个作业对应的作业列表
            case FLAG_NOTICE_OUT_BOUND_DETAILS_WORK_MAIN://通知单出库详情：单个作业对应的作业列表
                String stockName = "";
                String whName = "";
                String packageWeight = "";
                String amount = "";
                String weight = "";
                String volume = "";
                String stockStatus = "";
                String stockType = "";
                String unitName = "";
                String batchNo = "";
                String remark = "";
                String jobRecordNotice = "";
                ArrayList<JobAttachBean> jobAttachList = new ArrayList<>();//附件管理
                ArrayList<WorkNotesBean> jobAmountList = new ArrayList<>();//作业记录
                if (item.object instanceof JobInfoBean) {
                    JobInfoBean jobInfoBean = (JobInfoBean) item.object;
                    stockName = jobInfoBean.actualStockName;
                    whName = jobInfoBean.actualWhName;
                    packageWeight = String.valueOf(jobInfoBean.packageWeight);
                    amount = String.valueOf(jobInfoBean.actualAmount);
                    weight = String.valueOf(jobInfoBean.actualWeight);
                    volume = String.valueOf(jobInfoBean.actualVolume);
                    stockStatus = jobInfoBean.stockStatusName;
                    stockType = jobInfoBean.stockTypeName;
                    unitName = jobInfoBean.unitName;
                    batchNo = jobInfoBean.batchNo;
                    remark = jobInfoBean.remark;
                    if(jobInfoBean.getJobAmountList() != null && jobInfoBean.getJobAmountList().size() > 0){
                        jobAmountList.addAll(jobInfoBean.getJobAmountList());
                        String departName = jobInfoBean.getJobAmountList().get(0).getDepart();
                        jobRecordNotice = StringUtils.isEmpty(departName) ? "": departName;
                    }
                    if (jobInfoBean.getJobAttachList() != null && jobInfoBean.getJobAttachList().size() >0) {
                        jobAttachList.addAll(jobInfoBean.getJobAttachList());
                    }
                } else if (item.object instanceof PositionInfoBean) {
                    PositionInfoBean noteceOutBoundDetailPositionBean = (PositionInfoBean) item.object;
                    stockName = noteceOutBoundDetailPositionBean.stockName;
                    whName = noteceOutBoundDetailPositionBean.whName;
                    packageWeight = String.valueOf(noteceOutBoundDetailPositionBean.packageWeight);
                    amount = String.valueOf(noteceOutBoundDetailPositionBean.amount);
                    weight = String.valueOf(noteceOutBoundDetailPositionBean.weight);
                    volume = String.valueOf(noteceOutBoundDetailPositionBean.volume);
                    stockStatus = noteceOutBoundDetailPositionBean.stockStatusName;
                    stockType = noteceOutBoundDetailPositionBean.stockTypeName;
                    unitName = noteceOutBoundDetailPositionBean.unitName;
                    batchNo = noteceOutBoundDetailPositionBean.batchNo;
                    remark = noteceOutBoundDetailPositionBean.remark;
                    if(noteceOutBoundDetailPositionBean.getJobAmountList() != null && noteceOutBoundDetailPositionBean.getJobAmountList().size() > 0){
                        jobAmountList.addAll(noteceOutBoundDetailPositionBean.getJobAmountList());
                        String departName = noteceOutBoundDetailPositionBean.getJobAmountList().get(0).getDepart();
                        jobRecordNotice = StringUtils.isEmpty(departName) ? "": departName;
                    }
                    if (noteceOutBoundDetailPositionBean.getJobAttachList() != null && noteceOutBoundDetailPositionBean.getJobAttachList().size() > 0) {
                        jobAttachList.addAll(noteceOutBoundDetailPositionBean.getJobAttachList());
                    }
                }
                //                helper.setText(R.id.work_info_item_workOrderNumberTextView, );
                helper.setText(R.id.work_info_item_showReservoirPositionTv, stockName);//库位名称
                helper.setText(R.id.work_info_item_showStorehouseTv, whName);//仓库名称
                helper.setText(R.id.work_info_item_showUnitWeightTv, packageWeight.equals("null") ? "0": packageWeight);//单价总量
                helper.setText(R.id.work_info_item_showNumberForPieceTv, amount);//数量（件）
                helper.setText(R.id.work_info_item_showWeightForTonTv, weight);//重量(吨)
                helper.setText(R.id.work_info_item_showVolumeForSquareTv, volume);//体积(吨)
                helper.setText(R.id.work_info_item_showInventoryStatusTv, stockStatus);//库存状态
                helper.setText(R.id.work_info_item_showInventoryTypeTv, stockType);//库存类型
                helper.setText(R.id.work_info_item_showStandardTv, unitName);//规格
                helper.setText(R.id.work_info_item_showBatchNumberTv, batchNo);//批次号
                helper.setText(R.id.work_info_item_showRemarksTv, remark);//备注
                helper.setText(R.id.work_info_item_showJobRecordTv, jobRecordNotice);//作业记录
                helper.addOnClickListener(R.id.work_info_item_sureWorkBtn)
                .addOnClickListener(R.id.work_info_item_workDeleteTv)
                .addOnClickListener(R.id.work_info_item_showReservoirPositionTv)
                .addOnClickListener(R.id.work_info_item_showJobRecordTv);

                if (mAdapterFlag == FLAG_NOTICE_IN_BOUND_DETAILS_WORK_MAIN) {
                    // 入库时才可以选择 库存状态 等
                    addInventorysListener(helper);
                } else {
                    setInventorysOutType(helper);
                }

                MyGridView mGridView = helper.getView(R.id.work_info_item_gridView);
                GridViewImageAdapter mAdapter = new GridViewImageAdapter(mContext, helper.getLayoutPosition());
                mAdapter.setData(jobAttachList);
                mGridView.setAdapter(mAdapter);
                break;
            case FLAG_RECEIVING_GOODS_MAIN://收货确认列表
            case FLAG_SEND_GOODS_MAIN://发货确认列表
                TextView tvInOrOutBoundNoticeLetterNoTitle = helper.getView(R.id.inbound_location_main_item_inboundNoticeLetterNo);
                if (mAdapterFlag == FLAG_RECEIVING_GOODS_MAIN) {
                    tvInOrOutBoundNoticeLetterNoTitle.setText(mContext.getResources().getString(R.string.inboundNoticeLetterNo));
                } else {
                    tvInOrOutBoundNoticeLetterNoTitle.setText(mContext.getResources().getString(R.string.outboundNoticeLetterNo));
                }
                InAndOutBoundLocationBean receivingSendGoodsConfirmBean = (InAndOutBoundLocationBean) item.object;
                helper.setText(R.id.inbound_location_main_item_purchaseContentTv, receivingSendGoodsConfirmBean.bussTypeName);//订单类型名称
                helper.setText(R.id.inbound_location_main_item_positionStatusName, receivingSendGoodsConfirmBean.noticeOrderStatusName);//定库状态名称
                helper.setText(R.id.inbound_location_main_item_purchasePersonNameTv, receivingSendGoodsConfirmBean.driverName);//驾驶员姓名
                helper.setText(R.id.inbound_location_main_item_carIdCardTv, receivingSendGoodsConfirmBean.carNo);//车牌号
                helper.setText(R.id.inbound_location_main_item_timeTv, StringUtils.isEmpty(String.valueOf(receivingSendGoodsConfirmBean.addTime)) ? "" : DateUtils.getSimpleDateTimeByMill(String.valueOf(receivingSendGoodsConfirmBean.addTime), DateUtils.DATE_TIME_FORMAT));//建单时间
                helper.setText(R.id.inbound_location_main_item_showInboundNoticeLetterNo, receivingSendGoodsConfirmBean.noticeOrderNo);//入库通知单号
                helper.setText(R.id.inbound_location_main_item_showERPNo, receivingSendGoodsConfirmBean.erpOrderNo);//ERP订单号
                helper.getView(R.id.inbound_location_main_item_purchaseTypeTv).setVisibility(View.GONE);
                helper.addOnClickListener(R.id.inbound_location_main_item_lyParent);
                break;
            case FLAG_ORDER_IN_BOUND_DETAILS_MATREIEL_MAIN://订单入库详情：未作业、已作业（物料）列表
            case FLAG_ORDER_OUT_BOUND_DETAILS_MATREIEL_MAIN://订单出库详情：未作业、已作业（物料）列表
                WorkInfoBean orderDetailInfoBean = (WorkInfoBean) item.object;
                TextView tvOrderDetailMaterial = helper.getView(R.id.material_position_info_item_textView);
                tvOrderDetailMaterial.setText(orderDetailInfoBean.skuName);
                helper.addOnClickListener(R.id.materail_position_info_item_lyParent);
                setItemSelectedUI(tvOrderDetailMaterial, orderDetailInfoBean.isSelected);
                break;
            case FLAG_ORDER_IN_BOUND_DETAILS_WORK_MAIN://订单入库详情未作业、已作业列表
            case FLAG_ORDER_OUT_BOUND_DETAILS_WORK_MAIN://订单出库详情未作业、已作业列表
                String stockNameOrderBound = "";
                String whNameOrderBound = "";
                String packageWeightOrderBound = "";
                String amountOrderBound = "";
                String weightOrderBound = "";
                String volumeOrderBound = "";
                String stockStatusOrderBound = "";
                String stockTypeOrderBound = "";
                String unitIdOrderBound = "";
                String batchNoOrderBound = "";
                String remarkOrderBound = "";
                String jobRecordOrder = "";
                ArrayList<JobAttachBean> jobAttachListOrderBound = new ArrayList<>();//附件管理
                if (item.object instanceof JobInfoBean) {
                    JobInfoBean orderBoundDetailJobBean = (JobInfoBean) item.object;
                    stockNameOrderBound = orderBoundDetailJobBean.actualStockName;
                    whNameOrderBound = orderBoundDetailJobBean.actualWhName;
                    packageWeightOrderBound = String.valueOf(orderBoundDetailJobBean.packageWeight);
                    amountOrderBound = String.valueOf(orderBoundDetailJobBean.actualAmount);
                    weightOrderBound = String.valueOf(orderBoundDetailJobBean.actualWeight);
                    volumeOrderBound = String.valueOf(orderBoundDetailJobBean.actualVolume);
                    stockStatusOrderBound = orderBoundDetailJobBean.stockStatusName;
                    stockTypeOrderBound = orderBoundDetailJobBean.stockTypeName;
                    unitIdOrderBound = orderBoundDetailJobBean.unitName;
                    batchNoOrderBound = orderBoundDetailJobBean.batchNo;
                    remarkOrderBound = orderBoundDetailJobBean.remark;
                    jobRecordOrder = StringUtils.isEmpty(orderBoundDetailJobBean.jobRecord) ? "": orderBoundDetailJobBean.jobRecord;
                    if (orderBoundDetailJobBean.getJobAttachList() != null) {
                        jobAttachListOrderBound.addAll(orderBoundDetailJobBean.getJobAttachList());
                    }
                } else if (item.object instanceof PositionInfoBean) {
                    PositionInfoBean orderBoundDetailJobBean = (PositionInfoBean) item.object;
                    stockNameOrderBound = orderBoundDetailJobBean.stockName;
                    whNameOrderBound = orderBoundDetailJobBean.whName;
                    packageWeightOrderBound = String.valueOf(orderBoundDetailJobBean.packageWeight);
                    amountOrderBound = String.valueOf(orderBoundDetailJobBean.amount);
                    weightOrderBound = String.valueOf(orderBoundDetailJobBean.weight);
                    volumeOrderBound = String.valueOf(orderBoundDetailJobBean.volume);
                    stockStatusOrderBound = orderBoundDetailJobBean.stockStatusName;
                    stockTypeOrderBound = orderBoundDetailJobBean.stockTypeName;
                    unitIdOrderBound = orderBoundDetailJobBean.unitName;
                    batchNoOrderBound = orderBoundDetailJobBean.batchNo;
                    remarkOrderBound = orderBoundDetailJobBean.remark;
                    jobRecordOrder = StringUtils.isEmpty(orderBoundDetailJobBean.jobRecord) ? "": orderBoundDetailJobBean.jobRecord;
                    if (orderBoundDetailJobBean.getJobAttachList() != null) {
                        jobAttachListOrderBound.addAll(orderBoundDetailJobBean.getJobAttachList());
                    }
                }
                helper.setText(R.id.work_info_item_showReservoirPositionTv, stockNameOrderBound);//库位
                helper.setText(R.id.work_info_item_showStorehouseTv, whNameOrderBound);//仓库
                helper.setText(R.id.work_info_item_showUnitWeightTv, packageWeightOrderBound);//单位重量
                helper.setText(R.id.work_info_item_showNumberForPieceTv, amountOrderBound);//数量
                helper.setText(R.id.work_info_item_showWeightForTonTv, weightOrderBound);//重量
                helper.setText(R.id.work_info_item_showVolumeForSquareTv, volumeOrderBound);//体积
                helper.setText(R.id.work_info_item_showInventoryStatusTv, stockStatusOrderBound);//库存状态
                helper.setText(R.id.work_info_item_showInventoryTypeTv, stockTypeOrderBound);//库存类型
                helper.setText(R.id.work_info_item_showStandardTv, unitIdOrderBound);//规格
                helper.setText(R.id.work_info_item_showBatchNumberTv, batchNoOrderBound);//批次号
                helper.setText(R.id.work_info_item_showJobRecordTv, jobRecordOrder);//作业记录
                EditText edtOrderBoundDetail = helper.getView(R.id.work_info_item_showRemarksTv);//备注
                edtOrderBoundDetail.setText(StringUtils.isEmpty(remarkOrderBound) ? remarkOrderBound : "");
                helper.addOnClickListener(R.id.work_info_item_workDeleteTv)
                        .addOnClickListener(R.id.work_info_item_sureWorkBtn)
                        .addOnClickListener(R.id.work_info_item_showReservoirPositionTv)
                        .addOnClickListener(R.id.work_info_item_showJobRecordTv);
                if (mAdapterFlag == FLAG_ORDER_IN_BOUND_DETAILS_WORK_MAIN) {
                    // 入库时才可以选择 库存状态 等
                    addInventorysListener(helper);
                } else {
                    setInventorysOutType(helper);
                }
                MyGridView mOrderBoundDetailGridView = helper.getView(R.id.work_info_item_gridView);
                GridViewImageAdapter mOrderBoundDetailAdapter = new GridViewImageAdapter(mContext, helper.getLayoutPosition());
                mOrderBoundDetailAdapter.setData(jobAttachListOrderBound);
                mOrderBoundDetailGridView.setAdapter(mOrderBoundDetailAdapter);
                break;
            case FLAG_CHECK_MANAGER_MAIN:

                CheckManagerBean checkManagerBean = (CheckManagerBean) item.object;
                helper.setText(R.id.txt_check_name, "盘点名称：" + checkManagerBean.takingName);
                helper.setText(R.id.txt_check_type, "盘点方式：" + checkManagerBean.takingModeName);
                helper.setText(R.id.txt_check_status, checkManagerBean.takingStatusName);
                helper.setText(R.id.txt_time, Utils.long2Str(Long.valueOf(checkManagerBean.addTime)));
                helper.addOnClickListener(R.id.layout_check_root);
                break;

            case FLAG_CHECK_DEATILS_MAIN:
                CheckDetailBean checkDetailBean = (CheckDetailBean) item.object;
                helper.setText(R.id.txt_code, "物料编码：" + checkDetailBean.skuCode);
                helper.setText(R.id.txt_name, "物料名称：" + checkDetailBean.skuName);
                helper.setText(R.id.txt_type, "库存类型：" + checkDetailBean.stockType);
                helper.setText(R.id.txt_spec, "规格：" + checkDetailBean.unitName);
                helper.setText(R.id.txt_status, "库存状态：" + checkDetailBean.stockStatusName);
                helper.setText(R.id.txt_batch_num, "批次号：" + checkDetailBean.batchNo);
                helper.setText(R.id.txt_check_num, "盘点数量：" + checkDetailBean.amountTaking);

                break;
            case FLAG_CHANGE_AND_GET_NOTIFY_LIST_MAIN:
                ChangeHouseConfirmBean changeHouseConfirmBean = (ChangeHouseConfirmBean) item.object;
                helper.setText(R.id.txt_name, "移库单号：" + changeHouseConfirmBean.noticeOrderNo);
                helper.setText(R.id.txt_status, changeHouseConfirmBean.noticeOrderStatusName);
                helper.setText(R.id.txt_type, "移库单类型：" + changeHouseConfirmBean.orderTypeName);
                helper.setText(R.id.txt_out, "出库仓库：" + changeHouseConfirmBean.tfOutWhName);
                helper.setText(R.id.txt_in, "入库仓库：" + changeHouseConfirmBean.tfInWhName);
                helper.setText(R.id.txt_time, Utils.long2Str(Long.valueOf(changeHouseConfirmBean.addTime)));
                helper.addOnClickListener(R.id.layout_root);
                break;
        }

    }

    private void addInventorysListener(BaseViewHolder helper) {
        helper.addOnClickListener(R.id.work_info_item_showInventoryStatusTv)
                .addOnClickListener(R.id.work_info_item_showInventoryTypeTv)
                .addOnClickListener(R.id.work_info_item_showStandardTv);
    }
    private void setInventorysOutType(BaseViewHolder helper) {
        int px = Utils.dp2px(10);
        int pxR = Utils.dp2px(30);
        ((TextView)helper.getView(R.id.work_info_item_showInventoryStatusTv)).setCompoundDrawables(null, null, null, null);
        helper.getView(R.id.work_info_item_showInventoryStatusTv).setPadding(px,px,pxR,px);
        ((TextView)helper.getView(R.id.work_info_item_showInventoryTypeTv)).setCompoundDrawables(null, null, null, null);
        helper.getView(R.id.work_info_item_showInventoryTypeTv).setPadding(px,px,pxR,px);
        ((TextView)helper.getView(R.id.work_info_item_showStandardTv)).setCompoundDrawables(null, null, null, null);
        helper.getView(R.id.work_info_item_showStandardTv).setPadding(px,px,pxR,px);
    }
    /**
     * 设置已作业、未作业item点击后的选中状态
     * 设置已定位、未定位item点击后的选中状态
     *
     * @param textView
     * @param isSelected
     */
    private void setItemSelectedUI(TextView textView, boolean isSelected) {
        if (isSelected) {
            textView.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.shape_search_btn_blue_bg));
            textView.setTextColor(mContext.getResources().getColor(R.color.whiteColor));
        } else {
            textView.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.shape_search_btn_gray_bg));
            textView.setTextColor(mContext.getResources().getColor(R.color.color_gray));
        }
    }

    /**
     * 设置适配器标识
     * 注：该数据必须在set适配器前调用
     *
     * @param flag
     */
    public void setAdapterFlag(int flag) {
        this.mAdapterFlag = flag;
    }

    private String getResourcesString(int resId) {
        return mContext.getResources().getString(resId);
    }


}
